package io.sdl.common.sys.dao;

import io.sdl.common.dao.BaseDao;
import io.sdl.common.sys.entity.SdlMessageReadStatusEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 消息已读状态表
 * 
 * @author Dchen
 * @email 1211734836@qq.com
 * @date 2025-05-12 09:29:35
 */
@Mapper
public interface SdlMessageReadStatusDao extends BaseDao<SdlMessageReadStatusEntity> {

    // 检查是否已存在记录
    SdlMessageReadStatusEntity existsByMessageIdAndMessageTypeAndReceiverId(@Param("messageId") Long messageId,@Param("messageType") Integer messageType,@Param("receiverId") Long receiverId);

    //标记消息为已读
    SdlMessageReadStatusEntity findByMessageIdAndMessageTypeAndReceiverId(@Param("messageId")Long messageId,@Param("messageType") Integer messageType,@Param("receiverId") Long receiverId);

    //获取未读消息数量
    Integer countByMessageTypeAndReceiverIdAndIsRead(@Param("messageType") Integer messageType,@Param("receiverId") Long receiverId,@Param("isRead") Integer isRead);

    //获取未读消息列表
    List<SdlMessageReadStatusEntity> findMessageIdsByMessageTypeAndReceiverIdAndIsRead(@Param("messageType") Integer messageType,@Param("receiverId") Long receiverId,@Param("isRead") Integer isRead);
}
